﻿/*
 * Created by SharpDevelop.
 * User: XPMUser
 * Date: 11/1/2011
 * Time: 11:52 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.ComponentModel;
using System.Diagnostics;

namespace KDG.FoldersSize4
{
	/// <summary>
	/// Description of ViewModelBase.
	/// </summary>
	public class ViewModelBase : INotifyPropertyChanged 
	{
		public ViewModelBase()
		{
		}
		
		protected virtual void OnPropertyChanged(string propertyName)
		{
		    //this.VerifyPropertyName(propertyName);
		
		    PropertyChangedEventHandler handler = this.PropertyChanged;
		    if (handler != null)
		    {
		        var e = new PropertyChangedEventArgs(propertyName);
		        handler(this, e);
		    }
		}
		
		[Conditional("DEBUG")]
		[DebuggerStepThrough]
		public void VerifyPropertyName(string propertyName)
		{
		    // Verify that the property name matches a real,  
		    // public, instance property on this object.
		    if (TypeDescriptor.GetProperties(this)[propertyName] == null)
		    {
		        string msg = "Invalid property name: " + propertyName;
		
		        //if (this.ThrowOnInvalidPropertyName)
		            throw new Exception(msg);
		        //else
		        //    Debug.Fail(msg);
		    }
		}
		
		public event PropertyChangedEventHandler PropertyChanged;
	}
}
